package cn.wolfcode.lww.controller;

import cn.wolfcode.lww.domain.Comment;
import cn.wolfcode.lww.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
public class CommentController {
    @Autowired
    CommentService commentService;
@RequestMapping("/insertComment")
    public String insertComment(Comment comment){
    Date date = new Date();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
    simpleDateFormat.applyPattern("yyyy-MM-dd hh:mm:ss");
    String format = simpleDateFormat.format(date);
    comment.setTime(format);
    int insert = commentService.insert(comment);
    if (comment.getType()==1){
        return "redirect:/selectTravelByPrimaryKey?id="+comment.getArtId();
    }
    return "redirect:/selectByPrimaryKey?id="+comment.getArtId();
}
}
